package com.mmall.pay.enums;

/**
 * @author gg
 * @version PayStatusEnum.java, v 0.1 2019-05-27 18:11 gg
 */
public enum PayStatusEnum {

    NOT_PAY(1, "未支付"),
    PAID(2, "已支付"),
    CANCELED(3, "已取消"),
    FAILED(4, "已失败"),
    REFUNDED(5, "已退款"),
    CANCEL_REFUND(6, "取消退款"),
    REFUND_FAILED(7, "退款失败"),
    ;

    private String desc;
    private Integer code;

    PayStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * Getter method for property <tt>name</tt>.
     *
     * @return property value of name
     */
    public String getDesc() {
        return desc;
    }

    /**
     * Getter method for property <tt>value</tt>.
     *
     * @return property value of value
     */
    public Integer getCode() {
        return code;
    }

    public static PayStatusEnum getByValue(Integer value) {
        PayStatusEnum[] valueList = PayStatusEnum.values();
        for (PayStatusEnum v : valueList) {
            if (v.getCode().equals(value)) {
                return v;
            }
        }
        return null;
    }

    public static String getName(Integer value) {
        PayStatusEnum[] valueList = PayStatusEnum.values();
        for (PayStatusEnum v : valueList) {
            if (v.getCode().equals(value)) {
                return v.getDesc();
            }
        }
        return null;
    }
}